package customer.zspt.cn.customer.utils;

import customer.zspt.cn.customer.bean.ChatMsgDao;
import customer.zspt.cn.customer.constant.chatMsgFieldName;

/**
 * Created by Administrator on 2018/8/21 0021.
 */

public class SqlOptionsUtils {
    //添加消息进数据库的语句
    public static String SqlStr(String tableName, String avater, String content,
                                int send, long temptime, String userName
            , int State, int msgType, String groupAvater, String groupName, String chatobjAvater, String chatobjName,String dateTime) {
        String sql = "INSERT INTO " + tableName + "( " + chatMsgFieldName.AVATER
                + "," + chatMsgFieldName.CHATCONTENT +
                "," + chatMsgFieldName.SENDORFROM +
                "," + chatMsgFieldName.TEMPTIME +
                "," + chatMsgFieldName.USERNAME +
                "," + chatMsgFieldName.READORUNREAD +
                "," + chatMsgFieldName.MSGTYPE +
                "," + chatMsgFieldName.GROUPAVATAR +
                "," + chatMsgFieldName.GROUPNAME +
                "," + chatMsgFieldName.CHATOBJAVATER +
                "," + chatMsgFieldName.CHATOBJNAME +
                "," + chatMsgFieldName.DATETIME +
                ") VALUES ('" + avater +
                "','" + content + "'," + send + "," + temptime + ",'"
                + userName + "'," + State + "," +
                msgType + ",'" + groupAvater + "','" +
                groupName + "','" + chatobjAvater + "','" + chatobjName + "','"+dateTime+"');";
        return sql;
    }
    //转义消息
    public static ChatMsgDao getChatMsgDao(String avater, String content,
                                           int send, long temptime, String userName
            , int State, int msgType) {
        ChatMsgDao dao = new ChatMsgDao();
        dao.setAvater(avater);
        dao.setChatContent(content);
        dao.setMsgType(msgType);
        dao.setSendOrfrom(send);
        dao.setTempTime(temptime);
        dao.setReadOrUnRead(State);
        return dao;
    }
}
